package br.com.veterinariavillage.view.Veterinario;

import javax.swing.table.*;
import javax.swing.*;
//import java.awt.*;

@SuppressWarnings("serial")
public class TabelaVeterinarios extends JPanel {
    private JScrollPane spVeterinario;
    private JTable tbVeterinario;
    private JPanel pnBotoes;
    private JPanel pnFiltro;

    public TabelaVeterinarios() {
        inicializarComponentes();
    }
    
    private void inicializarComponentes() {

        pnFiltro = new OpcoesConsultaVeterinario();
        pnBotoes = new BotoesTabelaVeterinario();
        spVeterinario = new JScrollPane();
        tbVeterinario = new JTable();

//        pnFiltro.setPreferredSize(new Dimension(390, 112));
//        pnFiltro.setLayout(new BorderLayout());

        tbVeterinario.setModel(new DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Nome", "CRMV", "E-Mail", "Telefone", "Especialidade"
            }
        ) {
            @SuppressWarnings("rawtypes")
			Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false, false
            };

            @SuppressWarnings({ "rawtypes", "unchecked" })
			public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        spVeterinario.setViewportView(tbVeterinario);

//        pnBotoes.setPreferredSize(new Dimension(400, 45));

//        GroupLayout pnBotoesLayout = new GroupLayout(pnBotoes);
//        pnBotoes.setLayout(pnBotoesLayout);
//        pnBotoesLayout.setHorizontalGroup(
//            pnBotoesLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
//            .addGap(0, 0, Short.MAX_VALUE)
//        );
//        pnBotoesLayout.setVerticalGroup(
//            pnBotoesLayout.createParallelGroup(GroupLayout.Alignment.LEADING)
//            .addGap(0, 45, Short.MAX_VALUE)
//        );

        GroupLayout layout = new GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(GroupLayout.Alignment.TRAILING)
                    .addComponent(pnBotoes, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(pnFiltro, GroupLayout.Alignment.LEADING, GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
                    .addComponent(spVeterinario, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(11, 11, 11)
                .addComponent(pnFiltro, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(spVeterinario, GroupLayout.PREFERRED_SIZE, 168, GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(pnBotoes, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addContainerGap(14, Short.MAX_VALUE))
        );
        this.setLayout(layout);
    }

	public JPanel getPnBotoes() {
		return pnBotoes;
	}

	public void setPnBotoes(JPanel pnBotoes) {
		this.pnBotoes = pnBotoes;
	}
}
